package com.itheima.reggie.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.dto.SetmealDto;
import com.itheima.reggie.pojo.Dish;
import com.itheima.reggie.pojo.Setmeal;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

public interface SetmealDao extends BaseMapper<Setmeal> {
    @Select("select count(*) from setmeal where category_id=#{categoryId}")
    long findSetMealCountByCategoryId(Long categoryId);

    @Insert("INSERT INTO setmeal VALUES (null,#{categoryId},#{name},#{price},#{status},#{code},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser},0)")
    @Options(useGeneratedKeys = true, keyColumn = "id", keyProperty = "id")
    void save(SetmealDto setmealDto);

    List<SetmealDto> findPageByName(@Param("name") String name);

    @Delete("delete from setmeal where id=#{id}")
    void deleteById(Long id);


    @Select("select * from setmeal where id=#{id}")
    Setmeal findById(Long id);



    @Update("update setmeal set status=#{status} where id=#{id}")
    void updateStatus(@Param("status") Integer status,Long id);

    @Select("SELECT * FROM setmeal WHERE category_id = #{categoryId} AND `status`= #{status}")
    List<Setmeal> findBysetmealId(Long categoryId, Integer status);

    @Update("update setmeal set category_id=#{categoryId}, name=#{name},price=#{price},code=#{code},description=#{description},image=#{image},create_time=#{createTime},update_time=#{updateTime},create_user=#{createUser},update_user=#{updateUser},is_deleted=0 where id=#{id}")
    void update(SetmealDto setmealDto);
}
